<#assign pojo=oneToManyPojo.getOne()>
<#assign many=oneToManyPojo.getMany()>
<#assign ones=oneToManyPojo.getOnes()>
package ${pojo.getPackageName()}.dao;

<#assign classbody>
<#assign declarationName = pojo.importType(pojo.getDeclarationName())>
/**
 * @author bo.wang
 */
public abstract class Base${declarationName}Dao extends BaseMongoDBDao{

	public static final String BEAN_ID="${pojo.getDeclarationNameFirstLetterLower()}Dao";

	public DaoPage find${declarationName}ByParams(Map params, Integer pageIndex,Integer pageSize)
	{
		Query query=new Query();
		Map values=new HashMap();
		build${declarationName}Query(query, values, params);
		return pageBy(query, ${declarationName}Entity.class, pageIndex, pageSize);
	}
	public List<${declarationName}Entity> find${declarationName}ByParams(Map params)
	{
		Query query=new Query();
		Map values=new HashMap();
		build${declarationName}Query(query, values, params);
		return findBy(query, ${declarationName}Entity.class);
	}
	protected abstract void build${declarationName}Query(Query query,Map values,Map params);
<#assign parentid = pojo.getDeclarationNameFirstLetterLower()+"Id">
<#foreach child in many>
<#assign childdeclarationName = child.importType(child.getDeclarationName())>
	public DaoPage find${childdeclarationName}ByParams(Map params, Integer pageIndex,Integer pageSize)
	{
		Query query=new Query();
		Map values=new HashMap();
		build${childdeclarationName}Query(query, values, params);
		return pageBy(query, ${childdeclarationName}Entity.class, pageIndex, pageSize);
	}
	public List<${childdeclarationName}Entity> find${childdeclarationName}ByParams(Map params)
	{
		Query query=new Query();
		Map values=new HashMap();
		build${childdeclarationName}Query(query, values, params);
		return findBy(query, ${childdeclarationName}Entity.class);
	}
	protected abstract void build${childdeclarationName}Query(Query query,Map values,Map params);
</#foreach>
<#foreach child in ones>
<#assign childdeclarationName = child.importType(child.getDeclarationName())>	
	public ${childdeclarationName}Entity find${childdeclarationName}(Map params)
	{
		Query query=new Query();
		Map values=new HashMap();
		build${childdeclarationName}Query(query, values, params);
		return (${childdeclarationName}) getFirstRecord(findBy(query, ${childdeclarationName}Entity.class));
	}
	protected abstract void build${childdeclarationName}Query(StringBuffer query,Map values,Map params);
</#foreach>
}
</#assign>
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import com.ling.pl.core.commons.constant.TableColnumDef;
import com.ling.pl.core.commons.support.DaoPage;
import com.ling.pl.core.commons.utils.AssertHelper;
import com.ling.pl.core.dao.impl.BaseMongoDBDao;
import ${pojo.getModelPackageName()}.${declarationName};
import ${pojo.getModelPackageName()}.${declarationName}Entity;
<#foreach child in ones>
<#assign childdeclarationName = child.importType(child.getDeclarationName())>	
import ${child.getPackageName()}.model.${childdeclarationName};
import ${child.getPackageName()}.model.${childdeclarationName}Entity;
</#foreach>
<#foreach child in many>
<#assign childdeclarationName = child.importType(child.getDeclarationName())>
import ${child.getPackageName()}.model.${childdeclarationName};
import ${child.getPackageName()}.model.${childdeclarationName}Entity;
</#foreach>
${classbody}
